﻿//
//  Windows_libc
//
//  Created by  cc_team(陈旭，陈曦) qq:511272827.
//  Copyright 2011 cc_team. All rights reserved.
//
#ifndef CC_BIT_H
#define CC_BIT_H

#include "cc_common.h"
#include "cc_stdlib.h"

// get the bit value at index of the value, for example, getBit(4, 2) will return 1.
// the index is started by 0, also from right to left in binary mode.
// you should make sure the index value isn't overflowed!
#define GET_BIT(num, index)					(((num) >> (index)) & 1)

// also the set and clear bit value
// you should also make sure the index value isn't overflowed!
#define SET_BIT(num, index)					((num) |= (1 << (index)))
#define CLEAR_BIT(num, index)				((num) &= ~(1 << (index)))

__BEGIN_DECLS


__END_DECLS

#endif